package com.smartaccounting.service;

import com.smartaccounting.dao.ExpenseDAO;
import com.smartaccounting.model.Expense;

import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.List;

public class ExpenseService {
    private ExpenseDAO expenseDAO;

    public ExpenseService() {
        this.expenseDAO = new ExpenseDAO();
    }

    public boolean addExpense(Expense expense) throws SQLException {
        return expenseDAO.addExpense(expense);
    }

    public boolean updateExpense(Expense expense) throws SQLException {
        return expenseDAO.updateExpense(expense);
    }

    public boolean deleteExpense(int expenseId) throws SQLException {
        return expenseDAO.deleteExpense(expenseId);
    }

    public List<Expense> getUserExpenses(int userId) throws SQLException {
        return expenseDAO.getExpensesByUserId(userId);
    }

    public List<Expense> getUserExpensesByMonth(int userId, String monthYear) throws SQLException {
        return expenseDAO.getExpensesByUserIdAndMonth(userId, monthYear);
    }

    public BigDecimal getTotalExpenseByMonth(int userId, String monthYear) throws SQLException {
        return expenseDAO.getTotalExpenseByUserIdAndMonth(userId, monthYear);
    }

    public List<Object[]> getExpenseCategorySummary(int userId, String monthYear) throws SQLException {
        return expenseDAO.getExpenseCategorySummary(userId, monthYear);
    }

    public List<Object[]> getPaymentMethodSummary(int userId, String monthYear) throws SQLException {
        return expenseDAO.getPaymentMethodSummary(userId, monthYear);
    }
}